using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using CreamX.Framework.Game.Components;
using CreamX.Common;
namespace CreamX.Framework.Game
{
    public class RectangleCollisionBody : SceneCollisionBody
    {

        public BoundingBox BoundingBox
        {
            get { return _sceneObject.GetBoundingBox(); }
        }

        public RectangleCollisionBody(CreamXObject sceneobject)
        {
            _sceneObject = sceneobject;
        }
        CreamXCollisionData co = new CreamXCollisionData();
        internal override void TestMove(float time, Vector2 velocity, List<CreamXCollisionData> collisions, CreamXObject hit)
        {
            CreamXCollisionComponent col = hit.GetComponent<CreamXCollisionComponent>();
            bool _hit = false;
            switch (col.CollisionType)
            {
                case CollisionType.Circle:
                    _hit = BoundingBox.Intersects(hit.GetBoundingSphere());
                    break;
                case CollisionType.Square:
                    _hit = BoundingBox.Intersects(hit.GetBoundingBox());
                    break;
            }

            if (_hit)
            {

                co.SceneObject = hit;
                collisions.Add(co);
            }
        }
    }
  
}
